-
Notifications
You must be signed in to change notification settings - Fork 674
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[testing] Switch to logging with zap #3557
Conversation
tests/log.go
Outdated
// TODO(marun) Figure out why this is outputting e.g. `Level(-6)` instead of `INFO` | ||
EncodeLevel: zapcore.LowercaseLevelEncoder, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have modified how levels are encoded. We should be providing a custom leveler like in the rest of avalanchego:
func levelEncoder(l zapcore.Level, enc zapcore.PrimitiveArrayEncoder) {
enc.AppendString(Level(l).String())
}
func jsonLevelEncoder(l zapcore.Level, enc zapcore.PrimitiveArrayEncoder) {
enc.AppendString(Level(l).LowerString())
}
See utils/logging/format.go#newTermEncoderConfig
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any objection to exporting these functions so they can be reused?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope - makes sense to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Co-authored-by: Stephen Buttolph <[email protected]> Signed-off-by: marun <[email protected]>
Co-authored-by: Stephen Buttolph <[email protected]> Signed-off-by: marun <[email protected]>
Co-authored-by: Stephen Buttolph <[email protected]> Signed-off-by: marun <[email protected]>
Co-authored-by: Stephen Buttolph <[email protected]> Signed-off-by: marun <[email protected]>
Co-authored-by: Stephen Buttolph <[email protected]> Signed-off-by: marun <[email protected]>
Co-authored-by: Stephen Buttolph <[email protected]> Signed-off-by: marun <[email protected]>
Co-authored-by: Stephen Buttolph <[email protected]> Signed-off-by: marun <[email protected]>
Co-authored-by: Stephen Buttolph <[email protected]> Signed-off-by: marun <[email protected]>
Co-authored-by: Stephen Buttolph <[email protected]> Signed-off-by: marun <[email protected]>
cf8a4d4
to
292016a
Compare
Co-authored-by: Stephen Buttolph <[email protected]> Signed-off-by: marun <[email protected]>
Why this should be merged
Previously testing used an incoherent mix of
TestContext.Outf
,fmt.Print
andfmt.Fprint
. This PR switches everything to use the zap logger for consistency with the rest of avalanchego.How this works
How this was tested
CI
TODO
Level(-6)
instead ofINFO
Need to be documented in RELEASES.md?
N/A